package rn;

import java.io.BufferedReader;
import java.io.FileReader;
public class IConnectionFactory {
	IConnection conector;
	
	
	public IConnectionFactory() {
		FileReader fr = null;
		BufferedReader  br = null;		
		String linea = "";
		try {
 			fr = new FileReader("src/rn/conector.txt");
 			br = new BufferedReader(fr);			
 			linea = br.readLine();
		}
		catch (Exception e) {
			System.out.println("error de lectura");		
		}
		finally {
			try {
				fr.close();
			}
			catch (Exception e) {
				System.out.println("Error de cierre");
			}
		}
	
		try {
			conector = (IConnection) Class.forName(linea).newInstance();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}
	
	public IConnection getConector() {		
		return conector;
	}
	
}
